extends spinalhdl
snippet array_declare "declare array"
var ${1:name}: Array[${2:String}] = new Array[$2](${3:number})
endsnippet

snippet array_create "create array directly"
var ${1:name} = Array(${2:1, 2, 3})
endsnippet

snippet fun1 "function without parameter"
def ${1:name} = {${2:expression}}
endsnippet

snippet fun2 "function without parameter but with return value"
def ${1:name}: ${2:return_type} = {${3:expression}}
endsnippet

snippet fun3 "full function template"
def ${1:name}(${2:para: Int})${3: :Int} = {
    $4
}
endsnippet

snippet main "main function"
// scalac test.scala && scala Main
object Main {
    def main(args: Array[String]):Unit = {
        println("Hello, world!")
    }
}
endsnippet

snippet object "object"
object ${1:name} {
    $2
}
endsnippet

snippet class "a blueprint for object"
class ${1:name} {
    $2
}
endsnippet


snippet for_generator "iteration through collection"
for(${1:item} <- ${2:collection})
	$1 := 0
endsnippet

snippet for_to "iteration through Range"
for(${1:i} <- ${2:start} to ${3:end})
	$1 := 0
endsnippet

snippet for_until "iteration through Range"
for(${1:i} <- ${2:start} until ${3:end})
	$1 := 0
endsnippet

snippet when "Conditional Assignment Value"
when(${1:condition}){
    // Execute when cond1 is true
}.elsewhen(/*cond2*/) {
    // Execute when (not cond1) and cond2
}.otherwise{
}
endsnippet

snippet switch "the same function as when"
switch(${1:x}) {
  is(value1) {
    // Execute when x === value1
  }
  is(value2) {
    // Execute when x === value2
  }
  default {
    // Execute if none of precedent conditions met
  }
}
endsnippet
